#include <wiringPi.h>
#include <stdio.h>

#define LED1 2
#define LED2 3

PI_THREAD(LED1_Thread)   		//申明子线程
{
    printf("PI_THREAD(Serial_writeThread)\n");
    int v = 0;
    while(1)					//线程逻辑循环
    {
        delay(500);   v = !v;
        digitalWrite(LED2,v);
    }
}

int main(int argc,char **argv)
{
    if(wiringPiSetup() == -1){
        printf("setup wiringPi failed !");
        return 1;
    }
    printf("Hello world!\n");

    pinMode(LED1, OUTPUT);
    pinMode(LED2, OUTPUT);

	//线程逻辑循环
    int res = piThreadCreate(LED1_Thread);
    if(res != 0)
    {
        printf("KeyScan didn't start\n");
    }

    int v = 0;
    while(1)
    {
        v = !v;
        digitalWrite(LED1,v);
        delay(1000);
    }
    return 0;
}

